package com.gexiaobao.pigeon.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.model.bean.PassListResponse

/**
 * @author:hxw
 * @date  :2023/1/30
 * @desc  :
 */
class PassListAdapter(data: ArrayList<PassListResponse.DataList>) :
    BaseQuickAdapter<PassListResponse.DataList, BaseViewHolder>(R.layout.item_pass_list, data) {

    override fun convert(holder: BaseViewHolder, item: PassListResponse.DataList) {
        holder.setText(R.id.tv_item_race_pass_name, item.passName)
        holder.setText(R.id.tv_item_race_pass_time, item.loadTime)
        holder.setText(R.id.tv_item_race_race_time, item.flyTime)

        var statusStr = "未开始"
        var statusColor = context.resources.getColor(R.color.color_8F8F8F)
        var statusIcon = R.mipmap.profilepic_str_1

        when (item.passStatus) {
            "1" -> {
                statusStr = "未开始"
                statusColor = context.resources.getColor(R.color.race_blue)
                statusIcon = R.mipmap.racing_blue
            }

            "2" -> {
                statusStr = "报名中"
                statusColor = context.resources.getColor(R.color.race_orange)
                statusIcon = R.mipmap.racing_orange
            }

            "3" -> {
                statusStr = "报名结束"
                statusColor = context.resources.getColor(R.color.race_grey)
                statusIcon = R.mipmap.racing_grey
            }

            "4" -> {
                statusStr = "集鸽中"
                statusColor = context.resources.getColor(R.color.race_blue)
                statusIcon = R.mipmap.racing_blue
            }

            "5" -> {
                statusStr = "集鸽结束"
                statusColor = context.resources.getColor(R.color.race_blue)
                statusIcon = R.mipmap.racing_blue
            }

            "6" -> {
                statusStr = "比赛中"
                statusColor = context.resources.getColor(R.color.race_red)
                statusIcon = R.mipmap.racing_red
            }

            "7" -> {
                statusStr = "比赛结束"
                statusColor = context.resources.getColor(R.color.race_grey)
                statusIcon = R.mipmap.racing_grey
            }

            "8" -> {
                statusStr = "开始中"
                statusColor = context.resources.getColor(R.color.race_blue)
                statusIcon = R.mipmap.racing_blue
            }

            "9" -> {
                statusStr = "验鸽中"
                statusColor = context.resources.getColor(R.color.race_blue)
                statusIcon = R.mipmap.racing_blue
            }

            "10" -> {
                statusStr = "结束中"
                statusColor = context.resources.getColor(R.color.race_grey)
                statusIcon = R.mipmap.racing_grey
            }

        }
        holder.setText(R.id.tv_item_race_pass_status, statusStr)
        holder.setTextColor(R.id.tv_item_race_pass_status, statusColor)
        holder.setBackgroundResource(R.id.iv_item_race_pass_icon, statusIcon)
    }
}